﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient ;


namespace SJK
{
    public partial class 系统登录2 : Form
    {
        public 系统登录2()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //首页 f3 = new 首页();
            //f3.Show();
            if (tb_name.Text.Trim() == "" || tb_pwd.Text.Trim() == "")
            {
                MessageBox.Show("用户名或密码不能为空！");
                tb_name.Focus();
                return;
            }
            string connString = "Data Source=SERVER-42;Initial Catalog=sjk11;uid=jsj;pwd=2wsx@WSX";
            string sqlStr = string.Format("select count(*) from [tb_Operator1] where Name='{0}' and Password='{1}'", tb_name.Text.Trim(), tb_pwd.Text.Trim());
            using (SqlConnection conn = new SqlConnection(connString))
            {
                SqlCommand cmd = new SqlCommand(sqlStr, conn);
                conn.Open();
                int n = Convert.ToInt32(cmd.ExecuteScalar());
                if (n == 1)
                {
                    首页 f3 = new 首页();
                    f3.Show();
                }
                else
                {
                    MessageBox.Show("用户名或密码错误，请重新输入！");
                    tb_name.Text = "";
                    tb_pwd.Text = "";
                    tb_name.Focus();
                }
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();

        }
    }
}
